﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackPoint : MonoBehaviour
{

    public bool PointActive=false;   //回溯点激活
    public GameObject PlayerFactory;

    private Animator anim;     //动画
    void Start()
    {
        PlayerFactory = GameObject.Find("PlayerFactory");
        anim = GetComponent<Animator>();
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player")&&!PointActive) //未激活时
        {
            PointActive = true;

            //todo 切换回溯点动画;
            anim.SetTrigger("up");

            //修改工厂的回溯点
            PlayerFactory.GetComponent<playerFactory>().SetBlackPoint(this.gameObject);
            //清空残影未使用完的数据和角色存储的数据
            PlayerFactory.GetComponent<playerFactory>().ClearData();
        }
    }
}
